package com.sui.bigdata.rtcadmin.controller;

import com.sui.bigdata.rtcadmin.model.dto.ResourceInfoDto;
import com.sui.bigdata.rtcadmin.model.vo.CommonResponse;
import com.sui.bigdata.rtcadmin.service.ResourceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: TingWuHuang
 * @Date: 2020/7/2 11:00
 * @description
 */
@RestController
@RequestMapping("resource")
public class ResourceController {

    @Autowired
    ResourceInfoService resourceInfoService;

    @RequestMapping(value="/add", method = RequestMethod.POST)
    public CommonResponse add(@RequestParam("file") MultipartFile file, String remarks, String fileName, String resource){
        return resourceInfoService.add(file, remarks, fileName, resource);
    }

    @RequestMapping(value="/update", method = RequestMethod.POST)
    public CommonResponse update(@RequestParam("file") MultipartFile file, String remarks, String fileName, String resource){
        return resourceInfoService.update(file, remarks, fileName, resource);
    }

    @RequestMapping(value="/delete", method = RequestMethod.GET)
    public CommonResponse delete(String fileName){
        return resourceInfoService.deleteFile(fileName);
    }

    @RequestMapping(value="/query", method = RequestMethod.GET)
    public CommonResponse select(ResourceInfoDto resourceInfoDto){
        return resourceInfoService.select(resourceInfoDto);
    }

}
